<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" class="input">
    <button>确定</button>
    <div style="overflow:auto;width:300px;height:300px;"></div>
    <script>
        var button=document.querySelector("button");
        var input=document.querySelector(".input");
        var div=document.querySelector("div");
        button.addEventListener("click",fun);
        function fun(){
           let a=input.value;
           div.innerHTML+="<p><span>"+a+"</span><button onclick='del(this)'>删除</button></p>";
           input.value=null;
        }
        function del(a){
            var f=a;
            var fu=a.parentNode;//获取他的父级元素
            fu.remove();//删除元素
        }
    </script>
</body>
</html>